﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "外语等级考试 - 网上报名 - 报名科目");

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		termId = event.getArg("TermID");

		/* 学籍相关信息 */
		studentId = sessionAdvice.getAutherUserID();
		//studentClassId = sessionAdvice.getUserProp("studentClass");
		//studentSubjectId = sessionAdvice.getUserProp("studentSubject");
		//studentDirId = sessionAdvice.getUserProp("studentSubDir");
		studentGrade = sessionAdvice.getUserProp("studentGrade");
		studentDepartment = sessionAdvice.getUserProp("studentDepartment");
		
		today = datetimeAdvice.getCurrentDateString();
		currentTime = datetimeAdvice.getCurrentTimeString("HHMM");
		
		currentTab = event.getArg("TabID", "labWizard");
		
		/* 可报考科目 */ 			
		sql = "SELECT 
					a.exam_id, a.exam_name, 
					a.date_start, a.date_end,
					a.time_start, a.time_end,
					a.grade_allowed, a.institute_allowed,  
					a.exam_charge  
					FROM t_cet a 
					WHERE 
						SUBSTR(a.exam_prop, 1, 1) = '1' 
						AND
						(a.date_start < :today 
 						 	OR a.date_start = :today) 
						AND
						(a.date_end > :today 
  							OR a.date_end = :today) 
					ORDER BY a.exam_id ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="today", value=today, cfsqltype="cf_sql_char" );
		rs_cet = queryObj.execute( sql=sql ).getResult();
		
		/* 本期已报考并且已缴费的科目 */ 
		sql = "SELECT 
					t_cet.exam_id, t_cet.exam_name, 
					t_cet.date_start, t_cet.date_end,
					t_cet.time_start, t_cet.time_end,
					t_cet.grade_allowed, t_cet.institute_allowed,  
					t_cet.exam_charge  
				FROM t_cet_entry a 
					 INNER JOIN t_cet ON t_cet.exam_id = a.exam_id  
				WHERE 
					a.stu_id = :stuId 
					AND 
					a.term_id = :termId 
					AND 
					a.is_charged ='1' 
				ORDER BY a.eid DESC ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="stuId", value=studentId, cfsqltype="cf_sql_varchar" );
		rs_entry = queryObj.execute( sql=sql ).getResult();
		try {
		
			sign = event.getArg("ST");
			key = studentId & studentGrade & studentDepartment;
		
			cetTarget = decrypt(sign, key, "PBEWithMD5AndDES", "Hex");
		
		}
		catch ( any expt ) {
			cetTarget = "";
		}
		
		passArg = structNew();
		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">外语等级考试</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>报考语言和级别
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="programCourse">
				<div class="UItab2">
					<div class="tabLables">
						<span <cfif currentTab eq "labWizard">class="active"</cfif> id="labWizard" tabTarget="Wizard">语言级别</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
			 <!--- 描述：增加报名限制每学期只能报考一门等级考试 修改时间：2013-09-24 修改人：wenhaibo  --->
				<div id="Wizard" class="tabContent">
					<cfif rs_entry.recordCount >
							
							<div class="noticeBlock">
								<h3>本学期已报考并且已缴费的科目</h3>
								<p><span class="img icon16x16 message"></span>学生每学期只能报考一门等级考试科目.</p>
								<hr/>
							</div>
								
							<table id="cetList" class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td width="140">语言级别</td>
										<td width="220">报考时间段</td>
										<td width="60">报名费</td>
										<td>可报考年级</td>
										<td>报考学院</td>
									</tr>
								</thead>
								<tbody>
					 
										<cfloop query="rs_entry" >
										<cfset structInsert(passArg, "EX", rs_entry.exam_id, true) />

										<tr class="editRows" rowid="<cfoutput>#rs_entry.exam_id#</cfoutput>">
											<td >
											<a href="#" class="stat locked"></a>
											</td>
											<td><span class="numeric bold"><cfoutput>#rs_entry.exam_id#</cfoutput> - </span><strong><cfoutput>#rs_entry.exam_name#</cfoutput></strong></td>
											<td>
												<span class="numeric"><cfoutput>#datetimeAdvice.formatDateString(rs_entry.date_start, 'MM/DD')#</cfoutput> - <cfoutput>#datetimeAdvice.formatDateString(rs_entry.date_end, 'MM/DD')#</cfoutput></span>
												<cfif rs_entry.time_start eq "0001" and rs_entry.time_end eq "2359">
													全天
													<cfelse>
													<span class="numeric"><cfoutput>#datetimeAdvice.formatTimeString(rs_entry.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString(rs_entry.time_end, 'HH:MI')#</cfoutput></span>	
												</cfif>
											</td>
											<td><span class="numeric bold"><cfoutput>#numberFormat(rs_entry.exam_charge, '__.__')#</cfoutput></span></td>
											<td><cfif rs_entry.grade_allowed eq "ALL">全部<cfelse><span class="numeric"><cfoutput>#replace(rs_entry.grade_allowed, ",", " | ", "all")#</cfoutput></span></cfif></td>
											<td>
												<cfif rs_entry.institute_allowed eq "ALL">全部
													<cfelse> 
                                                    <cfset sql = "SELECT a.institute_short 
																	FROM t_institute a 
																	WHERE a.institute_id 
																		  IN 
																		  (:insIds )" />
                                                    <cfset queryObj = new Query( datasource=application.dnsSlave ) />
                                                    <cfset queryObj.addParam( name="insIds", value=rs_entry.institute_allowed, cfsqltype="cf_sql_varchar" ,list = true) />
                                                    <cfset rs_insSelect = queryObj.execute( sql=sql ).getResult() />
													<cfoutput>#valueList(rs_insSelect.institute_short, " | ")#</cfoutput>
												</cfif>
											</td>
										</tr>
							
									</cfloop>
								</tbody>
							</table>
					<cfelse>
					<cfif rs_cet.recordCount >
							
							<div class="noticeBlock">
								<h3>您当前可报考科目</h3>
								<p>请慎重选择本学期所报考的外语等级考试的语种和级别. 一旦报名结束, 所报考的科目就不能修改.</p>
								<hr/>
							</div>
								
							<table id="cetList" class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td></td>
										<td width="140">语言级别</td>
										<td width="220">报考时间段</td>
										<td width="60">报名费</td>
										<td>可报考年级</td>
										<td>报考学院</td>
									</tr>
								</thead>
								<tbody> 
										<cfloop query="rs_cet" >
										<cfset structInsert(passArg, "EX", rs_cet.exam_id, true) />

										<tr class="editRows" rowid="<cfoutput>#rs_cet.exam_id#</cfoutput>">
											<td>
												<!--- 报名时间段 --->
												<cfif ( rs_cet.time_start lte currentTime and currentTime lte rs_cet.time_end )>
													
													<!--- 判断年级学院是否在允许范围内 --->
													<cfif 
														( rs_cet.grade_allowed eq "ALL" or listFind(rs_cet.grade_allowed, studentGrade, ",") ) 
														and 
														( rs_cet.institute_allowed eq "ALL" or listFind(rs_cet.institute_allowed, studentDepartment, ",") )>
														
														<!--- 生成参数验证 --->
														<cfset string = rs_cet.exam_id />
														<cfset key = studentId & studentGrade & studentDepartment />
														<cfset sign = encrypt(string, key, "PBEWithMD5AndDES", "Hex") />
														
														<cfset structInsert(passArg, "ST", sign, true) />
														
														<!--- 可报考 语言级别 操作链接 --->
														<a href="<cfoutput>#buildURL('cetEntryWizardProfile', passArg)#</cfoutput>" class="stat <cfif cetTarget eq rs_cet.exam_id>on<cfelse>off</cfif>"></a>
													</cfif>
												</cfif>
												
												
											</td>
											<td class="cetFlag <cfoutput>#rs_cet.exam_id#</cfoutput>"></td>
											<td><span class="numeric bold"><cfoutput>#rs_cet.exam_id#</cfoutput> - </span><strong><cfoutput>#rs_cet.exam_name#</cfoutput></strong></td>
											<td>
												<span class="numeric"><cfoutput>#datetimeAdvice.formatDateString(rs_cet.date_start, 'MM/DD')#</cfoutput> - <cfoutput>#datetimeAdvice.formatDateString(rs_cet.date_end, 'MM/DD')#</cfoutput></span>
												<cfif rs_cet.time_start eq "0001" and rs_cet.time_end eq "2359">
													全天
													<cfelse>
													<span class="numeric"><cfoutput>#datetimeAdvice.formatTimeString(rs_cet.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString(rs_cet.time_end, 'HH:MI')#</cfoutput></span>	
												</cfif>
											</td>
											<td><span class="numeric bold"><cfoutput>#numberFormat(rs_cet.exam_charge, '__.__')#</cfoutput></span></td>
											<td><cfif rs_cet.grade_allowed eq "ALL">全部<cfelse><span class="numeric"><cfoutput>#replace(rs_cet.grade_allowed, ",", " | ", "all")#</cfoutput></span></cfif></td>
											<td>
												<cfif rs_cet.institute_allowed eq "ALL">全部
													<cfelse>
                                                     <cfset sql = "SELECT a.institute_short 
																	FROM t_institute a 
																	WHERE a.institute_id 
																		  IN 
																		  (:insIds )" />
                                                    <cfset queryObj = new Query( datasource=application.dnsSlave ) />
                                                    <cfset queryObj.addParam( name="insIds", value=rs_cet.institute_allowed, cfsqltype="cf_sql_varchar" ,list = true) />
                                                    <cfset rs_insSelect = queryObj.execute( sql=sql ).getResult() />
													<cfoutput>#valueList(rs_insSelect.institute_short, " | ")#</cfoutput>
												</cfif>
											</td>
										</tr>
							
									</cfloop>
								</tbody>
							</table>
							
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>没有可选的科目</h3>
								<p>可能目前不是报名时间段, 或者您不在允许的报名范围中.</p>
							</div>
					</cfif>
				</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>

